#!/bin/bash
# verify test

fname=f`date +%H%M%S`
mkdir $fname
for i in $(seq 0 20); do
  echo $i

  nachos -x ../test/testsort -rs $i > $fname/out2$i
  s3=`cat $fname/out2$i| grep -i '1023'|wc -l`
  if [ "$s3" -ne "2" ]
  then echo "../test/testsort $i : error ending\n" >> $fname/error; fi

  echo $i
  nachos -x ../test/testsort1 -rs $i > $fname/out3$i
  s4=`cat $fname/out3$i| grep -i '1023'|wc -l`
  if [ "$s4" -ne "2" ]
  then echo "../test/testsort1 $i : error ending\n" >> $fname/error; fi

  echo $i
  nachos -x ../test/testsort -rs $i -P RAND > $fname/out22$i
  s33=`cat $fname/out22$i| grep -i '1023'|wc -l`
  if [ "$s33" -ne "2" ]
  then echo "../test/testsort rand $i : error ending\n" >> $fname/error; fi

  echo $i
  nachos -x ../test/testsort1 -rs $i -P RAND > $fname/out33$i
  s44=`cat $fname/out33$i| grep -i '1023'|wc -l`
  if [ "$s44" -ne "2" ]
  then echo "../test/testsort1 rand $i : error ending\n" >> $fname/error; fi

#  for (( j=0; j < 12; j++))
#  do
#    cat $fname/out$i | grep -i "Group\ \[$j\]" >> $fname/resort$i
#    echo '\n' >> $fname/resort$i
#    if cat $fname/out$i|grep -i "Group\ \[$j\]" > /dev/null
#    then
#      if ! cat $fname/out$i|grep -i "Group\ \[$j\]\ is\ leaving\ TicketTaker" > /dev/null
#      then echo "test $i : group $j error ending" >> $fname/error; fi
#    fi
#  done
done

